package com.ruoyi.web.controller.smartHighway;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.smartHighway.domain.InspectionTask;
import com.ruoyi.smartHighway.service.IInspectionTaskService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 巡查任务信息Controller
 * 
 * @author ljj
 * @date 2024-08-01
 */
@Api("巡查任务信息")
@RestController
@RequestMapping("/smartHighway/inspectionTask")
public class InspectionTaskController extends BaseController {

    @Autowired
    private IInspectionTaskService inspectionTaskService;

    /**
     * 查询巡查任务信息列表
     */
    @ApiOperation("查询巡查任务信息列表")
    @PreAuthorize("@ss.hasPermi('smartHighway:inspectionTask:list')")
    @GetMapping("/list")
    public TableDataInfo list(InspectionTask inspectionTask) {
        startPage();
        List<InspectionTask> list = inspectionTaskService.selectInspectionTaskList(inspectionTask);
        return getDataTable(list);
    }

    /**
     * 导出巡查任务信息列表
     */
    @ApiOperation("导出巡查任务列表信息")
    @PreAuthorize("@ss.hasPermi('smartHighway:inspectionTask:export')")
    @Log(title = "巡查任务信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InspectionTask inspectionTask) {
        List<InspectionTask> list = inspectionTaskService.selectInspectionTaskList(inspectionTask);
        ExcelUtil<InspectionTask> util = new ExcelUtil<InspectionTask>(InspectionTask.class);
        util.exportExcel(response, list, "巡查任务信息数据");
    }

    /**
     * 获取巡查任务信息详细信息
     */
    @ApiOperation("获取巡查任务信息详细信息")
    @PreAuthorize("@ss.hasPermi('smartHighway:inspectionTask:query')")
    @GetMapping(value = "/{taskId}")
    public AjaxResult getInfo(@PathVariable("taskId") Long taskId) {
        return success(inspectionTaskService.selectInspectionTaskByTaskId(taskId));
    }

    /**
     * 新增巡查任务信息
     */
    @ApiOperation("新增巡查任务信息")
    @PreAuthorize("@ss.hasPermi('smartHighway:inspectionTask:add')")
    @Log(title = "巡查任务信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InspectionTask inspectionTask) {
        return toAjax(inspectionTaskService.insertInspectionTask(inspectionTask));
    }

    /**
     * 修改巡查任务信息
     */
    @ApiOperation("修改巡查任务信息")
    @PreAuthorize("@ss.hasPermi('smartHighway:inspectionTask:edit')")
    @Log(title = "巡查任务信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InspectionTask inspectionTask) {
        return toAjax(inspectionTaskService.updateInspectionTask(inspectionTask));
    }

    /**
     * 删除巡查任务信息
     */
    @ApiOperation("删除巡查任务信息")
    @PreAuthorize("@ss.hasPermi('smartHighway:inspectionTask:remove')")
    @Log(title = "巡查任务信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{taskIds}")
    public AjaxResult remove(@PathVariable Long[] taskIds) {
        return toAjax(inspectionTaskService.deleteInspectionTaskByTaskIds(taskIds));
    }
}
